package DynamicProgramming;

public class 使用最小花费爬楼梯 {
    public int minCostClimbingStairs(int[] cost) {
        int n = cost.length;
        int a = 0, b = 0;
        int res = 0;
        for (int i = 2; i <= n; i++) {
            res = Math.min(a + cost[i - 2], b + cost[i - 1]);
            a = b;
            b = res;
        }
        return res;
    }
}
